package com.bank;

/**
 * Created by Administrator on 2017/4/13.
 */

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.UiSelector;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;

import com.bank.lenovoz5.Z5CMBCbank;
import com.entity.SMSCode;
import com.entity.User;
import com.receive.SMSReceiverSend;
import com.show.api.util.StringUtils;
import com.utils.ChatClient;
import com.utils.Constants;
import com.utils.FileHelper;
import com.utils.ImageView;
import com.utils.LogToFile;
import com.utils.UIUtils;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.text.DecimalFormat;
import java.util.Timer;

import static android.os.SystemClock.sleep;
import static com.utils.ChatClient.C_updateBalance_W;
import static com.utils.ChatClient.ConfirmOrder;
import static com.utils.ChatClient.addWorkTime;
import static com.utils.ChatClient.getSerialNumber;
import static com.utils.ChatClient.getmap;
import static com.utils.ChatClient.list;
import static com.utils.ChatClient.mapDelete;
import static com.utils.ChatClient.requestSMSCode;
import static com.utils.ChatClient.user;
import static com.utils.ChatClient.userInfo;
import static com.utils.Constants.orderBankName;

/**
 * 不维护：K5，Z5 WebView元素获取不到。J7，S5设备停产
 * 民生银行自动化脚本
 */
@RunWith(AndroidJUnit4.class)
public class CMBCbank {
    private UiDevice mDevice;
    private Log Timber;
    private static String bankName = "CMBC";
    //定时刷新页面
    static Timer timer_num;
    private static String type = "abc";
    private static Context context = InstrumentationRegistry.getTargetContext();
    private static int[][] xy_abc = new int[][]{
            {44, 857}, {114, 857}, {184, 857}, {254, 857}, {324, 857}, {394, 857}, {464, 857}, {534, 857}, {604, 857}, {674, 857},
            {80, 975}, {150, 975}, {220, 975}, {290, 975}, {360, 975}, {430, 975}, {500, 975}, {570, 975}, {640, 975},
            {150, 1097}, {220, 1097}, {290, 1097}, {360, 1097}, {430, 1097}, {500, 1097}, {570, 1097}};
    private static int[][] xy_abc_2016 = new int[][]{
            {84, 1400}, {186, 1400}, {293, 1400}, {389, 1400}, {493, 1400}, {606, 1400}, {715, 1400}, {818, 1400}, {918, 1400},
            {1017, 1400},
            {122, 1580}, {222, 1580}, {330, 1580}, {433, 1580}, {557, 1580}, {655, 1580}, {773, 1580}, {863, 1580}, {970, 1580},
            {222, 1770}, {334, 1770}, {442, 1770}, {544, 1770}, {654, 1770}, {754, 1770}, {860, 1770}};
    private static int[][] xy_abc_2004 = new int[][]{
            {55, 1370}, {165, 1370}, {275, 1370}, {380, 1370}, {485, 1370}, {595, 1370}, {700, 1370}, {805, 1370}, {915, 1370},
            {1020, 1370},
            {110, 1545}, {220, 1545}, {320, 1545}, {430, 1545}, {540, 1545}, {650, 1545}, {750, 1545}, {860, 1545}, {965, 1545},
            {220, 1730}, {320, 1730}, {430, 1730}, {540, 1730}, {650, 1730}, {750, 1730}, {860, 1730}};
    private static int[][] xy_abc_1920 = new int[][]{
            {60, 1290}, {170, 1290}, {270, 1290}, {380, 1290}, {485, 1290}, {595, 1290}, {700, 1290}, {805, 1290}, {915, 1290},
            {1020, 1290},
            {110, 1465}, {220, 1465}, {320, 1465}, {430, 1465}, {540, 1465}, {650, 1465}, {750, 1465}, {860, 1465}, {965, 1465},
            {220, 1650}, {320, 1650}, {430, 1650}, {540, 1650}, {650, 1650}, {750, 1650}, {860, 1650}};
    private static int[][] xy_abc_1440 = new int[][]{
            {50, 1180}, {130, 1180}, {205, 1180}, {285, 1180}, {365, 1180}, {445, 1180}, {525, 1180}, {605, 1180}, {680, 1180},
            {760, 1180},
            {90, 1250}, {165, 1250}, {245, 1250}, {325, 1250}, {405, 1250}, {485, 1250}, {565, 1250}, {640, 1250}, {720, 1250},
            {170, 1325}, {250, 1325}, {325, 1325}, {405, 1325}, {485, 1325}, {565, 1325}, {640, 1325}};
    private static int[][] xy_abc_1280 = new int[][]{
            {45, 860}, {115, 860}, {185, 860}, {255, 860}, {325, 860}, {395, 860}, {465, 860}, {535, 860}, {605, 860}, {675, 860},
            {80, 980}, {150, 980}, {220, 980}, {290, 980}, {360, 980}, {430, 980}, {500, 980}, {570, 980}, {640, 980},
            {150, 1095}, {220, 1095}, {290, 1095}, {360, 1095}, {430, 1095}, {500, 1095}, {570, 1095}};
    private static int[][] xy_123 = new int[][]{
            {125, 855}, {355, 855}, {595, 855},
            {125, 975}, {355, 975}, {595, 975},
            {125, 1095}, {355, 1095}, {595, 1095},
            {355, 1220}};
    private static int[][] xy_123_2016 = new int[][]{
            {183, 1395}, {532, 1395}, {890, 1395},
            {183, 1580}, {532, 1580}, {890, 1580},
            {183, 1750}, {532, 1750}, {890, 1750},
            {532, 1936}};
    private static int[][] xy_123_2004 = new int[][]{
            {183, 1370}, {532, 1370}, {890, 1370},
            {183, 1550}, {532, 1580}, {890, 1580},
            {183, 1730}, {532, 1750}, {890, 1750},
            {532, 1910}};
    private static int[][] xy_123_1920 = new int[][]{
            {180, 1285}, {540, 1285}, {895, 1285},
            {180, 1465}, {540, 1465}, {895, 1465},
            {180, 1645}, {540, 1645}, {895, 1645},
            {540, 1825}};
    private static int[][] xy_123_1440 = new int[][]{
            {135, 1180}, {405, 1180}, {675, 1180},
            {135, 1255}, {405, 1255}, {675, 1255},
            {135, 1330}, {405, 1330}, {675, 1330},
            {405, 1400}};
    private static int[][] xy_123_1280 = new int[][]{
            {120, 857}, {360, 857}, {600, 857},
            {120, 980}, {360, 980}, {600, 980},
            {120, 1097}, {360, 1097}, {600, 1097},
            {360, 1218}};
    private static int[] tableAbc2Char = {0, 0};
    private static int[] tableAbc2Char_1280 = {115, 1215};
    private static int[] tableAbc2Char_1440 = {125, 1400};
    private static int[] tableAbc2Char_1920 = {112, 1830};
    private static int[] tableAbc2Char_2004 = {110, 1910};
    private static int[] tableAbc2Char_2016 = {107, 1945};
    private static int screenHeight = 0; // 手机屏幕高度
    private static float ratio = 1.0f;
    SMSReceiverSend sMSReceiverSend;
    private static String sumMoney = "";

    @Test
    public void demo() throws Exception {
        LogToFile.init(InstrumentationRegistry.getTargetContext(), Constants.PROT);
        mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
        if (!android.os.Build.MODEL.equals("SM-C710F")) {
            UIUtils.initServicePermission(mDevice);
        }
        if (android.os.Build.MODEL.equals("Lenovo L78011")) {
            showLog("联想Z5设备");
            new Z5CMBCbank(mDevice);
            return;
        }
        mDevice.pressHome();
        mDevice.pressHome();
        Exception exception = new Exception();
        StackTraceElement[] trace = exception.getStackTrace();
        String method = trace[0].getMethodName();
        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        int screenWidth = dm.widthPixels;
        //        int screenHeight = dm.heightPixels;
        screenHeight = dm.heightPixels;
        keyPhone(screenHeight);
        LogToFile.d("screenWidth:", "=====" + screenWidth);
        LogToFile.d("screenHeight:", "=====" + screenHeight);
        ratio = screenWidth / 720f;
        LogToFile.d("ratio:", "=====" + ratio);
        Constants.getsTheModelAndVersionNumberAndVersionName(context, "民生银行");
        //启动银行app
        UiObject x = mDevice.findObject(new UiSelector().text("民生银行"));
        x.click();
        //动态注册短信广播
        Constants.MOBILE_BOB = "95568";
        Constants.MOBILE_BOB_86 = "+8695568";
        sMSReceiverSend = new SMSReceiverSend();
        Constants.CODE = "";
        IntentFilter filter = new IntentFilter();
        filter.addAction(Constants.SMS_ACTION);
        filter.addAction("net.blogjava.mobile.SMSto");
        // 设置优先级 不然监听不到短信
        filter.setPriority(1000);
        context.registerReceiver(sMSReceiverSend, filter);
        Intent intent = new Intent();
        intent.setAction("com.tiantian.SEND_TO");
        context.sendBroadcast(intent);
        //动态注册sub连接状态广播
        //        CloseNetwork();
        //获取页面上我的账户节点
        ChatClient.begintime = System.currentTimeMillis();//开始时间
        while (true) {
            long nowtime = System.currentTimeMillis();
            if ((nowtime - ChatClient.begintime) > ChatClient.overtimeLogin) {
                ChatClient.timer(method, ChatClient.errorStr);
                return;
            }
            UiObject dialog1 = mDevice.findObject(new UiSelector().resourceId("cn.com.cmbc.newmbank:id/text_tv2"));
            if (dialog1.exists()) {
                LogToFile.d("-----进入首页------", "----点掉更新-------");
                dialog1.click();
                sleep(1000);
            }

            UiObject dialog = mDevice.findObject(new UiSelector().resourceId("cn.com.cmbc.newmbank:id/cancel_btn_bottom"));
            if (dialog.exists()) {
                LogToFile.d("-----进入首页------", "----点掉主页广告-------");
                dialog.click();
                sleep(1000);
            }

            UiObject zhuanzhang = mDevice.findObject(new UiSelector().text("转账").className("android.widget.TextView"));
            if (zhuanzhang.exists()) {
                sleep(1000);
                //进入转账
                zhuanzhang.click();
                ImageView dd = new ImageView();
                ImageView.saveImg("");
                //连接服务端
                ChatClient.start();
                LogToFile.d("-----连接服务端------", "----连接服务端-------");
                //获取账号信息
                ChatClient.begintime = System.currentTimeMillis();//开始时间
                while (true) {
                    long nowtime1 = System.currentTimeMillis();
                    if ((nowtime1 - ChatClient.begintime) > ChatClient.overtime) {
                        ChatClient.timer(method, ChatClient.errorStr);
                        return;
                    }
                    if (userInfo.equals("")) {
                        LogToFile.d("-----获取登陆信息------", "----获取登陆信息-------");
                        ChatClient.msg("<YZF>{'header':'" + ChatClient.M_GET_BANK_LOGIN_INFO_P + "'}</YZF>");
                        sleep(5000);
                    } else {
                        user = new User();
                        String[] res = userInfo.split(" ");
                        user.setUserName(res[0]);
                        user.setPwd(res[1]);
                        user.setBankpwd(res[2]);
                        user.setUsbPayPwd(res[3]);
                        user.setUseType(res[4]);
                        user.setBankId(res[5]);
                        LogToFile.d("-----获登陆信息------", "----登陆信息-------" + user.toString());
                        break;
                    }
                }
                sleep(1000);
                UiObject bar = mDevice.findObject(new UiSelector().text("转账汇款").className("android.widget.TextView"));
                LogToFile.d("-----检测转账汇款------", "----检测转账汇款-------");
                if (bar.exists()) {
                    LogToFile.d("-----点击转账汇款------", "----点击转账汇款-------");
                    bar.click();
                }
                sleep(4000);
                //检测登录
                UiObject login = mDevice.findObject(new UiSelector().text("登录手机银行").className("android.widget.TextView"));
                LogToFile.d("-----检测登录手机银行------", "----检测登录手机银行-------");
                if (login.exists()) {
                    LogToFile.d("-----准备登录------", "----准备登录-------");
                    Login();
                    break;
                }
                break;
            }
        }
    }

    //键盘适配
    private void keyPhone(int screenHeight) {
        //        carrier = android.os.Build.MODEL;
        String h = String.valueOf(screenHeight);
        switch (h) {
            case "1280":
                xy_abc = xy_abc_1280;
                xy_123 = xy_123_1280;
                tableAbc2Char = tableAbc2Char_1280;
                break;
            case "1440":
                xy_abc = xy_abc_1440;
                xy_123 = xy_123_1440;
                tableAbc2Char = tableAbc2Char_1440;
                break;
            case "1920":
                xy_abc = xy_abc_1920;
                xy_123 = xy_123_1920;
                tableAbc2Char = tableAbc2Char_1920;
                break;
            case "2016":
                xy_abc = xy_abc_2016;
                xy_123 = xy_123_2016;
                tableAbc2Char = tableAbc2Char_2016;
                break;
            case "2004":
                xy_abc = xy_abc_2004;
                xy_123 = xy_123_2004;
                tableAbc2Char = tableAbc2Char_2004;
                break;
        }


    }

    //进入登录页面补充用户信息
    public void Login() {
        try {
            sleep(4000);
            UiObject username = mDevice.findObject(new UiSelector().resourceId("cn.com.cmbc.newmbank:id/edtPhone"));
            if (user.getUserName() != null) {
                username.setText(user.getUserName());
            }
            UiObject pwd1 = mDevice.findObject(new UiSelector().resourceId("cn.com.cmbc.newmbank:id/edtPwd"));
            LogToFile.d("-----检测密码输入框------", "----检测密码输入框-------");
            if (pwd1.exists()) {
                pwd1.legacySetText("");
                pwd1.click();
            }
            //输入登录密码
            //截取键盘模拟用户输入登录密码
            if (user.getPwd() != null) {
                setClick(user.getPwd());
            }
            LogToFile.d("-----密码输入完成------", "----密码输入完成-------");
            sleep(1000);
            //点击登陆按钮
            clickLogin();
            //请求订单
            setRemittance();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 点击登陆按钮
     */
    private void clickLogin() {
        switch (screenHeight) {
            case 2016:
                LogToFile.d("-----点击登陆------", "----点击登陆-------");
                UiDevice.getInstance().click(580, 875);
                break;
            case 2004:
                LogToFile.d("-----点击登陆------", "----点击登陆-------");
                UiDevice.getInstance().click(540, 845);
                break;
            case 1920:
                LogToFile.d("-----点击登陆------", "----点击登陆-------");
                UiDevice.getInstance().click(540, 750);
                break;
            case 1440:
                LogToFile.d("-----点击登陆------", "----点击登陆-------");
                UiDevice.getInstance().click(400, 400);
                break;
            case 1280:
                LogToFile.d("-----点击登陆------", "----点击登陆-------");
                UiDevice.getInstance().click(357, 566);
                break;
        }
        sleep(2000);
        while (true) {
            UiObject zzBtn = mDevice.findObject(new UiSelector().text("转账").resourceId("cn.com.cmbc.newmbank:id/tv_title"));
            UiObject zzBtn1 = mDevice.findObject(new UiSelector().descriptionContains("转账").resourceId("cn.com.cmbc.newmbank:id/tv_title"));
            if (zzBtn.exists()) {
                LogToFile.d("-----检测到转账汇款控件------", "----检测到转账汇款控件-------");
                //登录成功
                ChatClient.loginS();
                LogToFile.d("-----登陆成功------", "----登陆成功-------");
                sleep(1000);
                break;
            } else if (zzBtn1.exists()) {
                LogToFile.d("-----检测到转账汇款控件------", "----检测到转账汇款控件-------");
                //登录成功
                ChatClient.loginS();
                LogToFile.d("-----登陆成功------", "----登陆成功-------");
                sleep(1000);
                break;
            }
        }
    }

    /**
     * 点击转账汇款按键
     */
    private void clickBtn() throws UiObjectNotFoundException {
        //        new MonitoringInstrumentation();
        //        mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
        mDevice.waitForIdle(ChatClient.overtime_10);
        sleep(2000);
        ChatClient.begintime = System.currentTimeMillis();//开始时间
        while (true) {
            long nowtime1 = System.currentTimeMillis();
            if ((nowtime1 - ChatClient.begintime) > ChatClient.overtime_15) {
                showLog("点击转账汇款");
                mDevice.click(540, 700);
                return;
            }
            UiObject zzBtn = mDevice.findObject(new UiSelector().text("转账汇款").className("android.widget.Button"));
            UiObject zzBtn1 = mDevice.findObject(new UiSelector().descriptionContains("转账汇款").className("android.widget.Button"));
            if (zzBtn.exists()) {
                LogToFile.d("-----点击转账汇款控件------", "----点击转账汇款控件-------");
                zzBtn.click();
                break;
            } else if (zzBtn1.exists()) {
                LogToFile.d("-----点击转账汇款控件------", "----点击转账汇款控件-------");
                zzBtn1.click();
                break;
            }
            sleep(ChatClient.overtime_3);
        }
    }

    /**
     * 登录成功后进入转账
     *
     * @throws UiObjectNotFoundException
     */
    private void setRemittance() throws UiObjectNotFoundException {
        sleep(3000);
        if (list.size() > 0) {
            LogToFile.d("是否查单状态", "是否查单状态：" + ConfirmOrder);
            //            if (ConfirmOrder){
            orderBankName = Constants.getBank(list.get(0).getBankName(), "CMBC");
            if (ConfirmOrder) {
                //查账
                clickBtn();
                LogToFile.d("-----有待确认订单，准备进入查账------", "-----有待确认订单，准备进入查账------");
                auditOrder();
            } else {
                clickBtn();
                LogToFile.d("-----有订单，进入转账------", "-----有订单，进入转账------");
                remittanceLongin();
            }
            //                    RUNING = true;
        } else {
            clickBtn();
            LogToFile.d("-----没有订单，获取订单------", "-----没有订单，获取订单------");
            remittance();
            //                    RUNING = false;
        }

    }

    /***
     * 查账
     *
     * */
    private void auditOrder() throws UiObjectNotFoundException {
        sleep(ChatClient.overtime_5);
        while (true) {
            sleep(2000);
            UiObject view2 = null;
            switch (screenHeight) {
                case 1280:
                    UiObject fl = mDevice.findObject(new UiSelector().className("android.widget.FrameLayout").resourceId("cn.com.cmbc" +
                            ".newmbank:id/webViewobject"));
                    UiObject webView1 = fl.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                    UiObject webView2 = webView1.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                    view2 = webView2.getChild(new UiSelector().className("android.view.View").index(15));
                    break;
                default:
                    UiObject view = mDevice.findObject(new UiSelector().className("android.view.View").resourceId("cnt-wrapper"));
                    UiObject view1 = view.getChild(new UiSelector().className("android.view.View").index(2));
                    view2 = view1.getChild(new UiSelector().className("android.view.View").index(5));
                    break;
            }
            LogToFile.d("---检测余额---", "---检测余额---");
            if (view2.exists()) {
                if (screenHeight == 1280) {
                    sumMoney = view2.getContentDescription();
                    if (StringUtils.isEmpty(sumMoney)) {
                        sumMoney = view2.getText();
                    }
                } else {
                    sumMoney = view2.getText();
                    if (StringUtils.isEmpty(sumMoney)) {
                        sumMoney = view2.getContentDescription();
                    }
                }
                sumMoney = sumMoney.replaceAll("元", "");
                sumMoney = sumMoney.replaceAll(",", "");
                Log.d("---检测到余额为---", "---检测到余额为---" + sumMoney);
                if (!StringUtils.isEmpty(sumMoney)) {
                    try {
                        //上报余额
                        C_updateBalance_W(Double.parseDouble(sumMoney));
                    } catch (NumberFormatException e) {
                        LogToFile.d("---获取到余额错误---", "---获取到余额sumMoney不能转换---");
                    }
                }
                break;
            }
        }
        sleep(2000);
        back();//返回
        sleep(2000);
        while (true) {
            UiObject view = mDevice.findObject(new UiSelector().text("转账历史/电子回单").className("android.view.View"));
            UiObject view1 = mDevice.findObject(new UiSelector().descriptionContains("转账历史/电子回单").className("android.view.View"));
            LogToFile.d("-----检测转账历史------", "-----检测转账历史------");
            if (view.exists()) {
                LogToFile.d("-----点击转账历史------", "-----点击转账历史------");
                view.click();
                break;
            } else if (view1.exists()) {
                LogToFile.d("-----点击转账历史------", "-----点击转账历史------");
                view1.click();
                break;
            }
        }
        sleep(2000);
        String name = "";
        String bankNo = "";
        String money = "";
        while (true) {
            UiObject view4 = null;
            if (screenHeight == 1280) {
                UiObject layout = mDevice.findObject(new UiSelector().className("android.widget.FrameLayout").resourceId("cn.com.cmbc" +
                        ".newmbank:id/webViewobject"));
                UiObject webview1 = layout.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                view4 = webview1.getChild(new UiSelector().className("android.webkit.WebView").index(0));
            } else {
                UiObject view = mDevice.findObject(new UiSelector().className("android.view.View").resourceId("cnt-wrapper"));
                UiObject view1 = view.getChild(new UiSelector().className("android.view.View").index(0));
                UiObject view2 = view1.getChild(new UiSelector().className("android.view.View").index(0));
                UiObject view3 = view2.getChild(new UiSelector().className("android.view.View").index(0));
                //            UiObject view4 = view3.getChild(new UiSelector().className("android.view.View").index(0));
                if (screenHeight == 1920) {
                    view4 = view3.getChild(new UiSelector().className("android.view.View").index(2));
                } else if (screenHeight == 2016) {
                    view4 = view3.getChild(new UiSelector().className("android.view.View").index(2));
                }
            }
            LogToFile.d("-----检测第一个转账历史------", "-----检测第一个转账历史------");
            UiObject mTV = null;
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            while (true) {
                long nowtime1 = System.currentTimeMillis();
                if ((nowtime1 - ChatClient.begintime) > ChatClient.overtime_5) {
                    LogToFile.d("-----检测第一个转账历史------", "-----非空白页------");
                    break;
                }
                mTV = mDevice.findObject(new UiSelector().text("暂无数据").className("android.view.View"));
                if (mTV.exists()) {
                    LogToFile.d("-----检测第一个转账历史------", "-----转账历史为空白页------");
                    break;
                }
            }
            if (view4.exists() || mTV.exists()) {
                String bankNo0 = null;
                String bankNo1 = null;
                String moery1 = null;
                if (!mTV.exists()) {
                    if (screenHeight == 1280) {
                        name = view4.getChild(new UiSelector().className("android.view.View").index(2)).getContentDescription();
                        bankNo = view4.getChild(new UiSelector().className("android.view.View").index(3)).getContentDescription();
                        money = view4.getChild(new UiSelector().className("android.view.View").index(4)).getContentDescription();
                    } else {
                        UiObject view5 = view4.getChild(new UiSelector().className("android.view.View").index(1));
                        name = view5.getChild(new UiSelector().className("android.view.View").index(0)).getText();
                        if (StringUtils.isEmpty(name)) {
                            name = view5.getChild(new UiSelector().className("android.view.View").index(0))
                                    .getContentDescription();
                        }
                        bankNo = view5.getChild(new UiSelector().className("android.view.View").index(1)).getText();
                        if (StringUtils.isEmpty(bankNo)) {
                            bankNo = view5.getChild(new UiSelector().className("android.view.View").index(1))
                                    .getContentDescription();
                        }
                        money = view5.getChild(new UiSelector().className("android.view.View").index(2)).getText();
                        if (StringUtils.isEmpty(money)) {
                            money = view5.getChild(new UiSelector().className("android.view.View").index(2))
                                    .getContentDescription();
                        }
                    }
                    money = money.replace("￥", "");
                    moery1 = money.replaceAll(",", "");
                    bankNo0 = list.get(0).getBankNo().substring(list.get(0).getBankNo().length() - 4, list.get(0).getBankNo
                            ().length());
                    bankNo1 = bankNo.substring(bankNo.length() - 4, bankNo.length());
                }
                LogToFile.d("-----第一个转账历史------", "姓名：" + name + ",卡号：" + bankNo + ",金额：" + money);
                String json = "";
                String mobileD = "";
                if (!StringUtils.isEmpty(moery1) && Double.parseDouble(list.get(0).getMoney()) == Double.parseDouble(moery1) &&
                        list.get(0).getUserName().equals(name) && !StringUtils.isEmpty(bankNo0) && !StringUtils.isEmpty
                        (bankNo1) && bankNo0.equals(bankNo1)) {
                    json = "'order':'" + list.get(0).getOrder() + "','balance':'" + sumMoney + "','state':0,'type':1";
                    mobileD = "'devices':'" + getSerialNumber() + "','prot':'" + Constants.PROT + "','phoneModel':'中国民生银行'," +
                            "'info':'交易成功'";
                } else {
                    String sumMoneyFile = user.getUserName() + bankName + "_sumMoney.txt";
                    String oldMoney = FileHelper.readSDFile(sumMoneyFile);
                    switch (Constants.changeInAmount(bankName, oldMoney, sumMoney, list.get(0).getMoney())) {
                        case "0":
                            json = "'order':'" + list.get(0).getOrder() + "','balance':'" + sumMoney + "','state':0,'type':1";
                            mobileD = "'devices':'" + getSerialNumber() + "','prot':'" + Constants.PROT + "','phoneModel':'中国民生银行'," +
                                    "'info':'交易成功'";
                            break;
                        case "1":
                            json = "'order':'" + list.get(0).getOrder() + "','balance':'" + sumMoney + "','state':1,'type':1";
                            mobileD = "'devices':'" + getSerialNumber() + "','prot':'" + Constants.PROT + "','phoneModel':'中国民生银行'," +
                                    "'info':'交易待处理...'";
                            break;
                        case "4":
                            json = "'order':'" + list.get(0).getOrder() + "','balance':'" + sumMoney + "','state':4,'type':1";
                            mobileD = "'devices':'" + getSerialNumber() + "','prot':'" + Constants.PROT + "','phoneModel':'中国民生银行'," +
                                    "'info':'未查到条目'";
                            break;
                    }
                }
                ChatClient.msg("<YZF>{'header':'" + ChatClient.S_CONFIRM_TRADE_RESULT_C + "'," + json + "," + mobileD +
                        "}</YZF>");
                //删除处理过的订单
                mapDelete(list.get(0).getOrder());
                getmap();
                LogToFile.d("=====转账记录查询完成====", "===转账记录查询完成=====");
                break;
            }
        }
        sleep(5000);
        back();
        setRemittance();
    }

    /**
     * 返回
     */
    private void back() {
        Log.d("==点击返回==", "=====点击返回====");
        switch (screenHeight) {
            case 1280:
                UiDevice.getInstance().click(60, 94);
                break;
            case 1920:
                UiDevice.getInstance().click(80, 120);
                break;
            case 2004:
                UiDevice.getInstance().click(95, 135);
                break;
            case 2016:
                UiDevice.getInstance().click(100, 180);
                break;
        }
    }

    /**
     * 转账汇款
     */
    private void remittanceLongin() throws UiObjectNotFoundException {
        sleep(ChatClient.overtime_3);
        UiObject mTV_money = null;
        while (true) {
            if (screenHeight == 1280) {
                UiObject fl = mDevice.findObject(new UiSelector().className("android.widget.FrameLayout").resourceId("cn.com.cmbc" +
                        ".newmbank:id/webViewobject"));
                UiObject webView1 = fl.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                UiObject webView2 = webView1.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                mTV_money = webView2.getChild(new UiSelector().className("android.view.View").index(15));
            } else {
                UiObject view = mDevice.findObject(new UiSelector().className("android.view.View").resourceId("cnt-wrapper"));
                UiObject view1 = view.getChild(new UiSelector().className("android.view.View").index(2));
                mTV_money = view1.getChild(new UiSelector().className("android.view.View").index(5));
            }
            LogToFile.d("---检测余额---", "---检测余额---");
            if (mTV_money.exists()) {
                if (screenHeight == 1280) {
                    sumMoney = mTV_money.getContentDescription();
                    if (StringUtils.isEmpty(sumMoney)) {
                        sumMoney = mTV_money.getText();
                    }
                } else {
                    sumMoney = mTV_money.getText();
                    if (StringUtils.isEmpty(sumMoney)) {
                        sumMoney = mTV_money.getContentDescription();
                    }
                }
                LogToFile.d("---获取到余额为---", "---获取到余额为---" + sumMoney);
                break;
            }
        }
        sumMoney = sumMoney.replaceAll(",", "");
        if (sumMoney.equals("")) {
            sumMoney = "-1";
        } else {
            LogToFile.d("====本地保存余额====", "===本地保存余额====:" + sumMoney);
            String sumMoneyFile = user.getUserName() + bankName + "_sumMoney.txt";
            FileHelper.saveMoneySDFile(false, sumMoney, sumMoneyFile);
        }
        //账户余额是否大于转账金额
        if (Double.parseDouble(sumMoney) < Double.parseDouble(list.get(0).getMoney())) {
            String mobileD = "'devices':'" + getSerialNumber() + "','prot':'" + Constants.PROT + "','phoneModel':'民生银行'," +
                    "'info':'账户余额不足'";
            String json = "'order':'" + list.get(0).getOrder() + "','balance':'" + sumMoney + "','state':1,'type':1";
            ChatClient.msg("<YZF>{'header':'" + ChatClient.M_SEND_TRADE_RESULT_P + "'," + json + "," + mobileD + "}</YZF>");
            LogToFile.d("-----余额不足-----", "-------余额不足--------");
            sleep(2000);
            //删除处理过的订单
            mapDelete(list.get(0).getOrder());
            getmap();
            //返回
            back();
            sleep(2000);
            clickBtn();
            sleep(2000);
            remittance();
        }
        LogToFile.d("---准备转账---", "---准备转账---");
        try {
            sleep(2000);
            LogToFile.d("---准备填入转账信息---", "---准备填入转账信息---");
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            while (true) {
                sleep(2000);
                long nowtime = System.currentTimeMillis();
                if ((nowtime - ChatClient.begintime) > 20 * 1000) {
                    LogToFile.d("---检测收款人姓名超时---", "---检测收款人姓名超时---");
                    break;
                }
                UiObject name = mDevice.findObject(new UiSelector().descriptionContains("请输入收款人户名").className("android.widget" +
                        ".EditText"));
                UiObject name1 = mDevice.findObject(new UiSelector().text("请输入收款人户名").className("android.widget.EditText"));
                LogToFile.d("---检测收款人姓名---", "---检测收款人姓名---");
                if (name.exists()) {
                    LogToFile.d("---输入收款人姓名---", "---输入收款人姓名---");
                    //                    name.click();
                    name.setText(list.get(0).getUserName());
                    break;
                } else if (name1.exists()) {
                    LogToFile.d("---输入收款人姓名---", "---输入收款人姓名---");
                    //                    name1.click();
                    name1.setText(list.get(0).getUserName());
                    break;
                }
            }
            addWorkTime(10000);
            sleep(2000);
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            while (true) {
                sleep(2000);
                UiObject bankNo = mDevice.findObject(new UiSelector().descriptionContains("请输入收款账号").className("android.widget" +
                        ".EditText"));
                UiObject bankNo1 = mDevice.findObject(new UiSelector().text("请输入收款账号").className("android.widget.EditText"));
                LogToFile.d("---检测收款账号---", "---检测收款账号---");
                if (bankNo.exists()) {
                    LogToFile.d("---输入收款账号---", "---输入收款账号---");
                    bankNo.setText(list.get(0).getBankNo());
                    break;
                } else if (bankNo1.exists()) {
                    LogToFile.d("---输入收款账号---", "---输入收款账号---");
                    bankNo1.setText(list.get(0).getBankNo());
                    break;
                }
            }
            addWorkTime(10000);
            sleep(2000);
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            //            String bankName = "";
            while (true) {
                sleep(2000);
                UiObject view = mDevice.findObject(new UiSelector().className("android.view.View").resourceId("cnt-wrapper"));
                UiObject view1 = view.getChild(new UiSelector().className("android.view.View").index(0));
                UiObject view2, view3, bank = null;
                switch (screenHeight) {
                    case 1920:
                        view2 = view1.getChild(new UiSelector().className("android.view.View").index(3));
                        view3 = view2.getChild(new UiSelector().className("android.view.View").index(0));
                        bank = view3.getChild(new UiSelector().className("android.view.View").index(1));
                        break;
                    case 2016:
                        view2 = view1.getChild(new UiSelector().className("android.view.View").index(3));
                        bank = view2.getChild(new UiSelector().className("android.view.View").index(1));
                        break;
                    case 2004:
                        view2 = view1.getChild(new UiSelector().className("android.view.View").index(3));
                        view3 = view2.getChild(new UiSelector().className("android.view.View").index(0));
                        bank = view3.getChild(new UiSelector().className("android.view.View").index(1));
                        break;
                    case 1280:
                        UiObject fl = mDevice.findObject(new UiSelector().className("android.widget.FrameLayout").resourceId("cn.com" +
                                ".cmbc.newmbank:id/webViewobject"));
                        UiObject webView1 = fl.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                        UiObject webView2 = webView1.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                        bank = webView2.getChild(new UiSelector().className("android.view.View").index(7));
                        break;
                }
                LogToFile.d("---检测收款人银行---", "---检测收款人银行---");
                //                bankName = orderBankName;
                if (bank.exists()) {
                    LogToFile.d("---设置收款人银行---", "---设置收款人银行---");
                    bank.click();
                    break;
                }
            }
            sleep(2000);
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            while (true) {
                sleep(2000);
                UiObject search = mDevice.findObject(new UiSelector().text("银行名称").className("android.widget.TextView").resourceId
                        ("cn.com.cmbc.newmbank:id/sh"));
                UiObject search1 = mDevice.findObject(new UiSelector().descriptionContains("银行名称").className("android.widget" +
                        ".TextView").resourceId("cn.com.cmbc.newmbank:id/sh"));
                LogToFile.d("---检测搜索框---", "---检测搜索框---");
                if (search.exists()) {
                    LogToFile.d("---点击搜索框---", "---点击搜索框---");
                    search.click();
                    break;
                } else if (search1.exists()) {
                    LogToFile.d("---点击搜索框---", "---点击搜索框---");
                    search1.click();
                    break;
                }
            }
            addWorkTime(10000);
            sleep(2000);
            while (true) {
                sleep(2000);
                UiObject et = mDevice.findObject(new UiSelector().text("银行名称").className("android.widget.EditText").resourceId("cn" +
                        ".com.cmbc.newmbank:id/sh_edtv"));
                UiObject et1 = mDevice.findObject(new UiSelector().descriptionContains("银行名称").className("android.widget.EditText")
                        .resourceId("cn.com.cmbc.newmbank:id/sh_edtv"));
                if (et.exists()) {
                    LogToFile.d("---设置收款银行---", "---设置收款银行---");
                    et.setText(orderBankName);
                    break;
                } else if (et1.exists()) {
                    LogToFile.d("---设置收款银行---", "---设置收款银行---");
                    et1.setText(orderBankName);
                    break;
                }
            }
            sleep(2000);
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            while (true) {
                sleep(2000);
                UiObject item = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc" +
                        ".newmbank:id/name"));
                LogToFile.d("---检测是否搜索到银行---", "---检测是否搜索到银行---");
                if (item.exists()) {
                    LogToFile.d("---点击搜索到的银行---", "---点击搜索到的银行---");
                    clickItem();
                    break;
                }
            }
            sleep(2000);
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            while (true) {
                UiObject money = mDevice.findObject(new UiSelector().text("￥ 请输入转账金额").className("android.view.View"));
                UiObject money1 = mDevice.findObject(new UiSelector().descriptionContains("￥ 请输入转账金额").className("android.view.View"));
                LogToFile.d("---检测金额输入框---", "---检测金额输入框---");
                if (money.exists()) {
                    LogToFile.d("---设置金额---", "---设置金额---");
                    money.click();
                    break;
                } else if (money1.exists()) {
                    LogToFile.d("---设置金额---", "---设置金额---");
                    money1.click();
                    break;
                }
            }
            addWorkTime(10000);
            LogToFile.d("---设置金额---", "---金额设置---");
            sleep(2000);
            while (true) {
                UiObject etMoney = mDevice.findObject(new UiSelector().className("android.widget.EditText").resourceId("cn.com.cmbc" +
                        ".newmbank:id/digitalText"));
                UiObject sure = mDevice.findObject(new UiSelector().className("android.widget.Button").resourceId("cn.com.cmbc" +
                        ".newmbank:id/btn_confirm"));
                LogToFile.d("---设置金额---", "---金额设置---");
                if (etMoney.exists()) {
                    etMoney.setText("");
                    etMoney.setText(list.get(0).getMoney());
                    sure.click();
                    break;
                }
            }

            sleep(1000);
            clickZZBtn();
            addWorkTime(10000);
            sleep(2000);
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            //检测是否有弹框
            while (true) {
                sleep(2000);
                long nowtime = System.currentTimeMillis();
                if ((nowtime - ChatClient.begintime) > ChatClient.overtime_8) {
                    LogToFile.d("---检测是否有弹框提示---", "---检测是否有弹框提示超时---");
                    break;
                }
                UiObject notice = mDevice.findObject(new UiSelector().text("提示").className("android.view.View"));
                UiObject dialog = mDevice.findObject(new UiSelector().className("android.app.Dialog"));
                UiObject view = dialog.getChild(new UiSelector().className("android.view.View").index(0));
                UiObject view1 = view.getChild(new UiSelector().className("android.view.View").index(0));
                UiObject view2_ = view1.getChild(new UiSelector().className("android.view.View").index(1));
                UiObject view3 = view2_.getChild(new UiSelector().className("android.view.View").index(0));
                LogToFile.d("---检测是否有弹框提示---", "---检测是否有弹框提示---");
                if (notice.exists()) {
                    if (view3.exists()) {
                        String info = view3.getText();
                        LogToFile.d("---获取提示信息---", "---获取提示信息---" + info);
                        alertError(info);
                        return;
                    }
                }
            }
            LogToFile.d("------准备输入U宝密码-----", "--------准备输入U宝密码------");
            sleep(2 * 1000);
            //            setClick_UB();
            LogToFile.d("------准备输入短信-----", "--------准备输入短信------");
            smsFlag = 0;
            getCodeType();
            sleep(ChatClient.overtime_3);
            errorSMSValidation();
            sleep(ChatClient.overtime_8);
            LogToFile.d("------转账结果页-----", "--------转账结果页------");
            ChatClient.msg("<YZF>{'header':'" + ChatClient.M_TRANSFERFINISH_P + "'}</YZF>");
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            while (true) {
                long nowtime = System.currentTimeMillis();
                if (nowtime - ChatClient.begintime > 60 * 1000) {
                    LogToFile.d("-----检测转账结果信息超时------", "----检测转账结果信息超时-------");
                    sendMsgInfo("未检测到转账结果");
                    return;
                }
                sleep(5000);
                UiObject mDialog_bottom = mDevice.findObject(new UiSelector().resourceId("cn.com.cmbc.newmbank:id/cancel_btn_bottom"));
                UiObject viewFail = mDevice.findObject(new UiSelector().text("转账失败").className("android.view.View"));
                UiObject viewFail1 = mDevice.findObject(new UiSelector().descriptionContains("转账失败").className("android.view.View"));
                UiObject viewSuccess = mDevice.findObject(new UiSelector().text("转账成功").className("android.view.View"));
                UiObject viewSuccess1 = mDevice.findObject(new UiSelector().descriptionContains("转账成功").className("android.view.View"));
                LogToFile.d("------检测转账结果信息-----", "--------检测转账结果信息------");
                if (mDialog_bottom.exists()) {
                    LogToFile.d("------检测转账结果信息-----", "--------关闭结果页广告------");
                    mDialog_bottom.click();
                }
                if (viewFail.exists()) {
                    sendMsgInfo("转账失败");
                    break;
                } else if (viewFail1.exists()) {
                    sendMsgInfo("转账失败");
                    break;
                } else if (viewSuccess.exists()) {
                    sendMsgInfo("转账成功");
                    break;
                } else if (viewSuccess1.exists()) {
                    sendMsgInfo("转账成功");
                    break;
                }
            }
            sleep(3000);
            while (true) {
                UiObject view = mDevice.findObject(new UiSelector().text("再转一笔").className("android.view.View"));
                UiObject view1 = mDevice.findObject(new UiSelector().descriptionContains("再转一笔").className("android.view.View"));
                LogToFile.d("------检测再转一笔-----", "--------检测再转一笔------");
                if (view.exists()) {
                    LogToFile.d("------点击继续转账-----", "--------点击继续转账------");
                    view.click();
                    break;
                } else if (view1.exists()) {
                    LogToFile.d("------点击继续转账-----", "--------点击继续转账------");
                    view1.click();
                    break;
                }
            }
            sleep(8000);
            back();
            LogToFile.d("------准备下一次转账-----", "--------准备下一次转账------");
            sleep(5000);
            setRemittance();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /***
     *
     * 点击转账页面的转账按钮
     * */
    private void clickZZBtn() throws UiObjectNotFoundException {
        UiObject zz, zz1 = null;
        while (true) {
            if (screenHeight == 1280) {
                UiObject fl = mDevice.findObject(new UiSelector().className("android.widget.FrameLayout").resourceId("cn.com.cmbc" +
                        ".newmbank:id/webViewobject"));
                UiObject webView1 = fl.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                UiObject webView2 = webView1.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                zz = webView2.getChild(new UiSelector().className("android.widget.Button").index(27));
                if (zz.exists()) {
                    LogToFile.d("---点击转账按钮---", "---点击转账按钮---");
                    zz.click();
                    break;
                }
            } else {
                zz = mDevice.findObject(new UiSelector().text("转 账").className("android.widget.Button"));
                zz1 = mDevice.findObject(new UiSelector().descriptionContains("转 账").className("android.widget.Button"));
                if (zz.exists()) {
                    LogToFile.d("---点击转账按钮---", "---点击转账按钮---");
                    zz.click();
                    break;
                } else if (zz1.exists()) {
                    LogToFile.d("---点击转账按钮---", "---点击转账按钮---");
                    zz1.click();
                    break;
                }
            }
            LogToFile.d("---检测转账按钮---", "---检测转账按钮---");
        }
    }

    /**
     * 设置U宝密码
     */
    //    private void setClick_UB() throws UiObjectNotFoundException {
    //        LogToFile.d("------切换认证方式-----", "--------切换认证方式------");
    //        addWorkTime((int) ChatClient.overtime_30);
    //        boolean isSelectUKey = true;
    //        ChatClient.begintime = System.currentTimeMillis();//开始时间
    //        while (true) {
    //            long nowtime = System.currentTimeMillis();
    //            if (nowtime - ChatClient.begintime > 30 * 1000) {
    //                LogToFile.d("-----检测认证方式控件超时------", "----检测认证方式控件超时-------");
    //                isSelectUKey = false;
    //                break;
    //            }
    //            sleep(2000);
    //            UiObject text = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc
    // .newmbank:id/uk_error_text"));
    //            //梁钊修改 适配联想新机型 2019年7月18日09:23:30
    //            if (!text.exists()) {
    //                text = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc.newmbank:id/tv_error_msg"));
    //            }
    //            UiObject type1 = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc" +
    //                    ".newmbank:id/tv_change_verify_type"));
    //            UiObject canncel = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc
    // .newmbank:id/tv_cancel"));
    //            LogToFile.d("------检测认证方式控件-lz----", "--------检测认证方式控件------");
    //            UiObject transactionPassword = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc" +
    //                    ".newmbank:id/tv_tips1"));
    //            if (transactionPassword.exists()) {
    //                if (type1.exists()) {
    //                    LogToFile.d("------点击返回-----", "--------点击返回------");
    //                    type1.click();
    //                }
    //            }
    //            sleep(4000);
    //            UiObject msg = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc
    // .newmbank:id/tv_sms_remind")
    //                    .index(3));
    //            UiObject type = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc" +
    //                    ".newmbank:id/tv_change_verify_type"));
    //            if (msg.exists()) {
    //                LogToFile.d("------进入到短信验证-----", "--------进入到短信验证------");
    //                if (type.exists()) {
    //                    LogToFile.d("------点击认证方式控件-----", "--------点击认证方式控件------");
    //                    type.click();
    //                    break;
    //                }
    //            } else if (text.exists()) {//检测连接U宝错误提示
    //                LogToFile.d("------错误提示-----", "--------错误提示------");
    //                String s = text.getText();
    //                LogToFile.d("------错误提示-----", "--------错误提示------" + s);
    //                String s1 = text.getContentDescription();
    //                LogToFile.d("------错误提示-----", "--------错误提示------" + s1);
    //                if (isBlueToothConnect(s) || isBlueToothConnect(s1)) {
    //                    LogToFile.d("------U宝连接错误-----", "--------U宝连接错误------");
    //                    if (canncel.exists()) {//连接中断，取消重新转账
    //                        LogToFile.d("------点击取消-----", "--------点击取消------");
    //                        canncel.click();
    //                        sleep(2000);
    //                        clickZZBtn();
    //                        sleep(2000);
    //                        LogToFile.d("------再次检测连接U宝-----", "--------再次检测连接U宝------");
    //                        setClick_UB();
    //                        return;
    //                    }
    //                }
    //            }
    //        }
    //        addWorkTime((int) ChatClient.overtime_15);
    //        if (isSelectUKey) {
    //            ChatClient.begintime = System.currentTimeMillis();//开始时间
    //            while (true) {
    //                long nowtime = System.currentTimeMillis();
    //                if (nowtime - ChatClient.begintime > ChatClient.overtime_5) {
    //                    LogToFile.d("-----检测切换认证方式控件------", "----检测切换认证方式控件超时-------");
    //                    break;
    //                }
    //                UiObject mTV_UKey = mDevice.findObject(new UiSelector().resourceId("cn.com.cmbc" +
    //                        ".newmbank:id/select_safe_tools_text_view")
    //                        .text("蓝牙U宝"));
    //                if (mTV_UKey.exists()) {
    //                    LogToFile.d("------切换认证方式-----", "--------点击U宝认证------");
    //                    mTV_UKey.click();
    //                    break;
    //                }
    //            }
    //        } else {
    //            isSelectUKey = true;
    //        }
    //        sleep(3000);
    //        while (true) {
    //            sleep(2000);
    //            UiObject edit = mDevice.findObject(new UiSelector().className("android.widget.EditText").resourceId("cn.com.cmbc" +
    //                    ".newmbank:id/uk_pin_edit"));
    //            UiObject sure = mDevice.findObject(new UiSelector().className("android.widget.Button").resourceId("cn.com.cmbc" +
    //                    ".newmbank:id/uk_bt_confirm"));
    //            UiObject error = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc" +
    //                    ".newmbank:id/uk_error_text"));
    //            UiObject canncel = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc" +
    //                    ".newmbank:id/tv_cancel"));
    //            LogToFile.d("------检测输入U宝密码界面-----", "--------检测输入U宝密码界面------");
    //            if (edit.exists()) {
    //                LogToFile.d("------准备点击U宝密码-----", "--------准备点击U宝密码------" + user.getUsbPayPwd());
    //                type = "abc";
    //                setClick(user.getUsbPayPwd());
    //                sleep(2000);
    //                if (sure.exists()) {
    //                    LogToFile.d("------输入完U宝密码，点击确定-----", "--------输入完U宝密码，点击确定------");
    //                    sure.click();
    //                    break;
    //                }
    //            } else if (error.exists()) {//检测连接U宝错误提示
    //                LogToFile.d("------错误提示-----", "--------错误提示------");
    //                String s = error.getText();
    //                LogToFile.d("------错误提示-----", "--------错误提示------" + s);
    //                String s1 = error.getContentDescription();
    //                LogToFile.d("------错误提示-----", "--------错误提示------" + s1);
    //                if (isBlueToothConnect(s) || isBlueToothConnect(s1)) {
    //                    LogToFile.d("------U宝连接错误-----", "--------U宝连接错误------");
    //                    if (canncel.exists()) {//连接中断，取消重新转
    //                        LogToFile.d("------点击取消-----", "--------点击取消------");
    //                        canncel.click();
    //                        sleep(2000);
    //                        clickZZBtn();
    //                        sleep(2000);
    //                        LogToFile.d("------再次检测连接U宝-----", "--------再次检测连接U宝------");
    //                        setClick_UB();
    //                        return;
    //                    }
    //                }
    //            }
    //        }
    //        sleep(2000);
    //        while (true) {
    //            sleep(1000);
    //            UiObject text = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc" +
    //                    ".newmbank:id/uk_state_text"));
    //            LogToFile.d("------检测U宝提示信息-----", "--------检测U宝提示信息------");
    //            if (text.exists()) {
    //                String s = text.getText();
    //                s = s.replace(" ", "");//格式化得到的信息
    //                LogToFile.d("------检测到U宝提示信息-----", "--------检测到U宝提示信息------" + s);
    //                String s1 = text.getContentDescription();
    //                s1 = s1.replace(" ", "");//格式化得到的信息
    //                LogToFile.d("------检测到U宝提示信息-----", "--------检测到U宝提示信息------" + s1);
    //                if (isCotaints(s) || isCotaints(s1)) {
    //                    LogToFile.d("------U宝密码输入完成，请在U宝上确定-----", "--------U宝密码输入完成，请在U宝上确定------");
    //                    pressu("1");
    //                    break;
    //                }
    //            }
    //        }
    //        sleep(2000);
    //        LogToFile.d("------准备输入取款密码-----", "--------准备输入取款密码------");
    //        while (true) {
    //            sleep(2000);
    //            UiObject text = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc" +
    //                    ".newmbank:id/tv_tips1"));
    //            LogToFile.d("------检测是否到输入取款密码界面-----", "--------检测是否到输入取款密码界面------");
    //            if (text.exists()) {
    //                String s = text.getText();
    //                if (StringUtils.isEmpty(s)) {
    //                    s = text.getContentDescription();
    //                }
    //                LogToFile.d("------取款密码界面信息-----", "--------取款密码界面信息------" + s);
    //                if (isCotaints(s)) {
    //                    LogToFile.d("------输入取款密码-----", "--------输入取款密码------");
    //                    setClickN(user.getBankpwd());
    //                    break;
    //                }
    //            }
    //        }
    //
    //    }

    /**
     * 检测是否和蓝牙U宝连接
     */
    private boolean isBlueToothConnect(String s) {
        boolean b = false;
        if (s.contains("蓝牙连接中断") || s.contains("蓝牙连接超时")) {
            b = true;
        }
        return b;
    }

    /**
     * 判断U宝界面的信息
     **/
    private boolean isCotaints(String s) {
        boolean b = false;
        if (s.contains("正在连接蓝牙U宝") || s.contains("请核实U宝屏显信息") || s.contains("交易密码")) {
            b = true;
        }
        return b;
    }


    /**
     * 处理无SIM卡手机短信逻辑
     */
    private void setNotSIM_SMS() {
        addWorkTime((int) ChatClient.overtime_60);
        sleep(ChatClient.overtime_15);
        SMSCode smsCode = requestSMSCode(user.getUserName(), user.getBankId());
        sleep(ChatClient.overtime_2);
        setClickN(smsCode.getSmscode());
    }

    private int smsFlag = 0;

    /**
     * 转账错误处理
     */
    private void errorSMSValidation() throws UiObjectNotFoundException {
        ChatClient.begintime = System.currentTimeMillis();
        while (true) {
            long nowTime1 = System.currentTimeMillis();
            if (nowTime1 - ChatClient.begintime > ChatClient.overtime_8) {
                showLog("账单错误超时");
                break;
            }
            String errorMsg = errorMsg();
            if (!StringUtils.isEmpty(errorMsg)) {
                if (errorMsg.contains("错误")) {
                    if (smsFlag < 3) {
                        smsFlag++;
                        LogToFile.d("------点击重新发送验证码-----", "--------点击重新发送验证码------");
                        switch (screenHeight) {
                            case 2016:
                                UiDevice.getInstance().click(810, 1150);
                                break;
                            case 1920:
                                UiDevice.getInstance().click(790, 1075);
                                break;
                        }
                        getCodeType();
                        break;
                    } else {
                        ChatClient.timer(Constants.getMethod(0), "短信获取超过三次");
                        return;
                    }
                }
            }
        }
    }

    private String errorMsg() throws UiObjectNotFoundException {
        UiObject errorMsgTitle = mDevice.findObject(new UiSelector().resourceId("cn.com.cmbc.newmbank:id/tv_process_state"));
        UiObject errorMsgBtn = mDevice.findObject(new UiSelector().resourceId("cn.com.cmbc.newmbank:id/tv_change_verify_type").text("重新认证"));
        String errorResult;
        if (errorMsgBtn.exists()) {
            errorResult = errorMsgTitle.getText();
            showLog("errorMsg  = " + errorResult);
            if (errorMsgBtn.exists()) {
                showLog("点击重新认证");
                errorMsgBtn.click();
                return errorResult;
            }
        }
        return "";
    }

    /**
     * 重新获取支付短信验证码
     */
    private void getCodeType() throws UiObjectNotFoundException {
        if (user.getUseType().equals("1")) {
            showLog("处理转账短信---真机");
            ChatClient.begintime = System.currentTimeMillis();
            while (true) {
                long nowTime1 = System.currentTimeMillis();
                if (nowTime1 - ChatClient.begintime > ChatClient.overtime_90) {
                    ChatClient.timer(LogToFile.getMethodName(), "短信验证码超时错误");
                    break;
                }
                if (TextUtils.isEmpty(Constants.CODE)) {
                    sleep(ChatClient.overtime_3);
                } else {
                    showLog("返回短信验证码为：" + Constants.CODE);
                    break;
                }
            }
        } else {
            showLog("处理转账短信---无SIM卡");
            setNotSIM_SMS();
        }

        sleep(2000);
        LogToFile.d("------准备输入取款密码-----", "--------准备输入取款密码------");
        while (true) {
            sleep(2000);
            UiObject text = mDevice.findObject(new UiSelector().className("android.widget.TextView").resourceId("cn.com.cmbc" +
                    ".newmbank:id/tv_tips1"));
            LogToFile.d("------检测是否到输入取款密码界面-----", "--------检测是否到输入取款密码界面------");
            if (text.exists()) {
                String s = text.getText();
                if (StringUtils.isEmpty(s)) {
                    s = text.getContentDescription();
                }
                LogToFile.d("------取款密码界面信息-----", "--------取款密码界面信息------" + s);
                if (isCotaints(s)) {
                    LogToFile.d("------输入取款密码-----", "--------输入取款密码------");
                    setClickN(user.getBankpwd());
                    break;
                }
            }
        }


        //
        //
        //
        //
        //
        //
        //
        //
        //
        //
        //
        //        Exception exception = new Exception();
        //        StackTraceElement[] trace = exception.getStackTrace();
        //        String method = trace[0].getMethodName();
        //        addWorkTime(20000);
        //        if (!"".equals(Constants.CODE)) {
        //            setClickN(Constants.CODE);
        //        } else {
        //            LogToFile.d("------点击重新发送验证码-----", "--------点击重新发送验证码------");
        //            switch (screenHeight) {
        //                case 2016:
        //                    UiDevice.getInstance().click(810, 1250);
        //                    break;
        //                case 2004:
        //                    UiDevice.getInstance().click(800, 1220);
        //                    break;
        //                case 1920:
        //                    UiDevice.getInstance().click(790, 1075);
        //                    break;
        //                case 1280:
        //                    UiDevice.getInstance().click(530, 757);
        //                    break;
        //            }
        //            sleep(8 * 1000);
        //            ChatClient.begintime = System.currentTimeMillis();//开始时间
        //            while (true) {
        //                long nowtime = System.currentTimeMillis();
        //                if ((nowtime - ChatClient.begintime) > ChatClient.overtime) {
        //                    LogToFile.d("------未获取到验证码-------", "--------未获取到验证码，可能由于弹框卡死界面引起的------");
        //                    ChatClient.timer(method, ChatClient.errorStr);
        //                    break;
        //                }
        //                if (!"".equals(Constants.CODE)) {
        //                    LogToFile.d("------重新输入验证码-----", "--------重新输入验证码------");
        //                    setClickN(Constants.CODE);
        //                    break;
        //                }
        //            }
        //        }
    }

    /**
     * 向服务端回馈转账结果
     */
    private void sendMsgInfo(String info) {
        String balance = "";

        String mobileD = "'devices':'" + getSerialNumber() + "','prot':'" + Constants.PROT + "','phoneModel':'民生银行','info':'" +
                info + "'";
        //            String json = "'order':'" + list.get(0).getOrder() + "','balance':'" + balance + "','state':" + Constants
        // .getStr(type) + "";
        String json;
        if (Constants.getStr(info) == 1) {
            json = "'order':'" + list.get(0).getOrder() + "','balance':'" + sumMoney + "','state':" + Constants.getStr(info) +
                    ",'type':1";
        } else {
            DecimalFormat formater = new DecimalFormat("#0.##");
            balance = formater.format(Double.parseDouble(sumMoney) - Double.parseDouble(list.get(0).getMoney()));
            json = "'order':'" + list.get(0).getOrder() + "','balance':'" + balance + "','state':" + Constants.getStr(info) + ",'type':1";
        }
        ChatClient.msg("<YZF>{'header':'" + ChatClient.M_SEND_TRADE_RESULT_P + "'," + json + "," + mobileD + "}</YZF>");
        //删除处理过的订单
        mapDelete(list.get(0).getOrder());
        getmap();
    }

    /**
     * 模拟点击密码
     *
     * @param pad_
     */
    public void setClickN(String pad_) {
        char[] abc = "1234567890".toCharArray();//char数组
        char[] pwd = pad_.toCharArray();//char数组
        Log.d("JUnit", "====---准备点击数字====");
        for (int j = 0; j < pwd.length; j++) {
            Log.d("JUnit", "====---准备点击数字:====" + pwd[j]);
            for (int i = 0; i < abc.length; i++) {
                Log.d("JUnit", "====---遍历数字:====" + abc[i]);
                if (abc[i] == pwd[j]) {
                    UiDevice.getInstance().click(xy_123[i][0], xy_123[i][1]);
                    LogToFile.d("====点击数字=====", "====点击数字====" + j);
                    sleep(1000);
                    break;
                }
            }
        }
    }

    private void clickItem() {
        String name = orderBankName;
        LogToFile.e("test", "===========clickItem==" + name + "==============");
        switch (screenHeight) {
            case 1280:
                if (name.contains("兴业")) {
                    UiDevice.getInstance().click(244, 398);
                } else {
                    UiDevice.getInstance().click(244, 305);
                }
                break;
            case 1920:
                if (name.contains("兴业")) {
                    UiDevice.getInstance().click(244, 597);
                } else {
                    UiDevice.getInstance().click(244, 400);
                }
                break;
            case 2004:
                if (name.contains("兴业")) {
                    UiDevice.getInstance().click(244, 615);
                } else {
                    UiDevice.getInstance().click(244, 460);
                }
                break;
            case 2016:
                if (name.contains("兴业")) {
                    UiDevice.getInstance().click(244, 620);
                } else {
                    UiDevice.getInstance().click(244, 470);
                }
                break;
        }
    }

    /**
     * 账户与姓名不符
     *
     * @param info type
     *             0 -- 失败
     *             1 -- 金额不足
     *             <p>
     *             state -- 6 (待确认)
     *             "" -- 待确认
     * @throws UiObjectNotFoundException
     */
    private void alertError(String info) throws UiObjectNotFoundException {
        LogToFile.d("=====检测是否有弹框====", "=====检测是否有弹框=====");
        sleep(2000);
        ChatClient.begintime = System.currentTimeMillis();//开始时间
        while (true) {
            long nowtime = System.currentTimeMillis();
            if ((nowtime - ChatClient.begintime) > 10 * 1000) {
                LogToFile.d("---检测弹框的按钮超时---", "---检测弹框的按钮超时---");
                break;
            }
            UiObject btn = mDevice.findObject(new UiSelector().text("返回修改").className("android.widget.Button"));
            UiObject btn1 = mDevice.findObject(new UiSelector().descriptionContains("返回修改").className("android.widget.Button"));
            LogToFile.d("---检测弹框的按钮---", "---检测弹框的按钮---");
            if (btn.exists()) {
                btn.click();
                break;
            } else if (btn1.exists()) {
                btn1.click();
                break;
            }
        }
        //LogToFile.d("=====账户余额不足====", "=====账户余额不足=====");
        ChatClient.begintime = System.currentTimeMillis();//开始时间
        String mobileD = "";
        String json = "";
        LogToFile.d("==转账错误信息==", "=====转账错误信息====" + info);
        info = info.replaceAll("\r|\n|\\s", "");
        if (isCheckStr(info)) {
            mobileD = "'devices':'" + getSerialNumber() + "','prot':'" + Constants.PROT + "','phoneModel':'民生银行','info':'" +
                    info + "'";
            json = "'order':'" + list.get(0).getOrder() + "','balance':'" + sumMoney + "','state':1,'type':1";
        } else {
            //待确认情况
            mobileD = "'devices':'" + getSerialNumber() + "','prot':'" + Constants.PROT + "','phoneModel':'民生银行','info':'" +
                    info + "'";
            json = "'order':'" + list.get(0).getOrder() + "','balance':'" + sumMoney + "','state':6,'type':1";
        }
        ChatClient.msg("<YZF>{'header':'" + ChatClient.M_SEND_TRADE_RESULT_P + "'," + json + "," + mobileD + "}</YZF>");
        //删除处理过的订单
        mapDelete(list.get(0).getOrder());
        getmap();
        sleep(5000);
        LogToFile.d("==转账失败信息==", "=====返回到立即转账界面====" + info);
        back();
        LogToFile.d("------准备下一次转账-----", "--------准备下一次转账------");
        setRemittance();
    }

    /**
     * 检测银行卡和姓名是否匹配
     */
    private boolean isCheckStr(String info) {
        boolean b = false;
        if (info.contains("请输入正确的收款人姓名") ||
                info.contains("请选择所属银行") || info.contains("可能有误，请核实")) {
            b = true;
        }
        return b;
    }

    /**
     * 进入短信验证
     *
     * @param balance:余额
     */
    private void setNext(String balance) {
        Exception exception = new Exception();
        StackTraceElement[] trace = exception.getStackTrace();
        String method = trace[0].getMethodName();
        try {
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            while (true) {
                long nowtime = System.currentTimeMillis();
                if ((nowtime - ChatClient.begintime) > ChatClient.overtime) {
                    ChatClient.timer(method, ChatClient.errorStr);
                    return;
                }
                //短信确定
                UiObject button2 = mDevice.findObject(new UiSelector().resourceId("android:id/button2"));
                if (button2.exists()) {
                    button2.click();
                    break;
                }
            }
            sleep(2000);
            UiDevice.getInstance().drag(200, 500, 540, 0, 10);
            sleep(5000);
            UiDevice.getInstance().click(190, 876);
            sleep(1000);
            //输入转账密码
            setClick(user.getBankpwd());
            sleep(1000);
            //转账密码确定
            UiDevice.getInstance().click(70, 750);
            sleep(1000);
            UiObject button3 = mDevice.findObject(new UiSelector().descriptionContains("转 账").className("android.widget.Button"));
            button3.click();
            ChatClient.msg("<YZF>{'header':'" + ChatClient.M_TRANSFERFINISH_P + "'}</YZF>");
            sleep(3000);
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            while (true) {
                long nowtime = System.currentTimeMillis();
                if ((nowtime - ChatClient.begintime) > ChatClient.overtime) {
                    ChatClient.timer(method, ChatClient.errorStr);
                    return;
                }
                UiObject in1 = mDevice.findObject(new UiSelector().text("转账结果").className("android.widget.TextView"));
                if (in1.exists()) {
                    sleep(2000);
                    getUserInfo(balance);
                    break;
                } else {
                    ChatClient.timer(method, "");
                    break;
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 完成转账后回复服务端
     * <p>
     * sumMoney：余额
     */
    private void getUserInfo(String sumMoney) {
        Exception exception = new Exception();
        StackTraceElement[] trace = exception.getStackTrace();
        String method = trace[0].getMethodName();
        try {

            sleep(2000);
            UiObject state = mDevice.findObject(new UiSelector().className("android.view.View").instance(1));
            String type = state.getContentDescription().trim();
            String balance = "";
            int s = 0;
            sleep(2000);
            if (Constants.getStr(type) == 0) {
                DecimalFormat formater = new DecimalFormat("#0.##");
                balance = formater.format(Double.parseDouble(sumMoney) - Double.parseDouble(list.get(0).getMoney()));
                s = 0;
            } else {
                balance = sumMoney;
                s = 1;
            }
            if (s == 1) {
                ChatClient.timer(method, "");
                return;
            }
            String mobileD = "'devices':'" + getSerialNumber() + "','prot':'" + Constants.PROT + "','phoneModel':'民生银行','info':'" +
                    type + "'";
            String json = "'order':'" + list.get(0).getOrder() + "','balance':'" + balance + "','state':" + Constants.getStr
                    (type) + "";
            ChatClient.msg("<YZF>{'header':'" + ChatClient.M_SEND_TRADE_RESULT_P + "'," + json + "," + mobileD + "}</YZF>");
            sleep(2000);
            //删除处理过的订单
            mapDelete(list.get(0).getOrder());
            getmap();
            UiDevice.getInstance().click(530, 580);
            //返回
            UiDevice.getInstance().click(80, 90);
            sleep(2000);
            remittance();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void remittance() {
        Exception exception = new Exception();
        StackTraceElement[] trace = exception.getStackTrace();
        String method = trace[0].getMethodName();
        LogToFile.d("=====返回页面等待订单====", "===返回页面查询订单=====");
        try {
            sleep(ChatClient.overtime_5);
            ChatClient.begintime = System.currentTimeMillis();//开始时间
            while (true) {
                sleep(2000);
                UiObject view2 = null;
                switch (screenHeight) {
                    case 1280:
                        UiObject fl = mDevice.findObject(new UiSelector().className("android.widget.FrameLayout").resourceId("cn.com" +
                                ".cmbc.newmbank:id/webViewobject"));
                        UiObject webView1 = fl.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                        UiObject webView2 = webView1.getChild(new UiSelector().className("android.webkit.WebView").index(0));
                        view2 = webView2.getChild(new UiSelector().className("android.view.View").index(15));
                        break;
                    default:
                        UiObject view = mDevice.findObject(new UiSelector().className("android.view.View").resourceId("cnt-wrapper"));
                        UiObject view1 = view.getChild(new UiSelector().className("android.view.View").index(2));
                        view2 = view1.getChild(new UiSelector().className("android.view.View").index(5));
                        break;
                }
                LogToFile.d("---检测余额---", "---检测余额---");
                if (view2.exists()) {
                    if (screenHeight == 1280) {
                        sumMoney = view2.getContentDescription();
                        if (StringUtils.isEmpty(sumMoney)) {
                            sumMoney = view2.getText();
                        }
                    } else {
                        sumMoney = view2.getText();
                        if (StringUtils.isEmpty(sumMoney)) {
                            sumMoney = view2.getContentDescription();
                        }
                    }
                    sumMoney = sumMoney.replaceAll("元", "");
                    sumMoney = sumMoney.replaceAll(",", "");
                    LogToFile.d("---检测到余额为---", "---检测到余额sumMoney为---" + sumMoney);
                    //上报余额
                    if (!StringUtils.isEmpty(sumMoney)) {
                        try {
                            double money = Double.parseDouble(sumMoney);
                            C_updateBalance_W(money);
                            LogToFile.d("====本地保存余额====", "===本地保存余额===");
                            String sumMoneyFile = user.getUserName() + bankName + "_sumMoney.txt";
                            FileHelper.saveMoneySDFile(false, sumMoney, sumMoneyFile);
                        } catch (Exception e) {
                            LogToFile.d("====sumMoney====", "===sumMoney不能转换===" + e.getMessage());
                        }
                    }
                    break;
                }
            }
            sleep(2000);
            if (list.size() > 0) {
                orderBankName = Constants.getBank(list.get(0).getBankName(), "CMBC");
                LogToFile.d("=====有订单====", "===有订单=====");
                sleep(4000);
                if (ConfirmOrder) {
                    //查账
                    LogToFile.d("-----有待确认订单，准备进入查账------", "-----有待确认订单，准备进入查账------");
                    auditOrder();
                } else {
                    LogToFile.d("-----有订单，进入转账------", "-----有订单，进入转账------");
                    remittanceLongin();
                }
            } else if (list.size() == 0) {
                LogToFile.d("=====没有订单====", "===没有订单=====");
                sleep(2000);
                back();
                sleep(5000);
                setTimerun();
            } else {
                ChatClient.timer(method, "");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void setTimerun() throws UiObjectNotFoundException {
        //        back();
        ChatClient.request();
        setRemittance();
    }

    /**
     * 模拟点击密码
     *
     * @param pad_
     */
    private void setClick(String pad_) {
        try {
            char[] abc = "qwertyuiopasdfghjklzxcvbnm".toCharArray();//char数组
            char[] num = "1234567890".toCharArray();//char数组
            char[] pwd = pad_.toCharArray();//char数组
            char[] num_abc;//char数组
            Log.d("-----密码------", "----密码-------" + pad_);
            for (int j = 0; j < pwd.length; j++) {
                if (isNumeric(String.valueOf(pwd[j]))) {
                    num_abc = num;
                } else {
                    num_abc = abc;
                }
                for (int i = 0; i < num_abc.length; i++) {
                    if (num_abc[i] == pwd[j]) {
                        if (isNumeric(String.valueOf(pwd[j]))) {
                            UiDevice.getInstance().click(xy_123[i][0], xy_123[i][1]);
                            sleep(1000);
                            Log.d("====---点击字母====" + pwd[j], xy_abc[i][0] + "，" + xy_abc[i][1]);
                        } else {
                            UiDevice.getInstance().click(xy_abc[i][0], xy_abc[i][1]);
                            sleep(1000);
                            Log.d("====---点击字母====" + pwd[j], xy_abc[i][0] + "，" + xy_abc[i][1]);
                        }
                        break;
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 字母和数字键盘的切换
     *
     * @param checkStr
     * @return
     */
    private boolean isNumeric(String checkStr) {
        try {
            Integer.parseInt(checkStr);
            //切换数字键盘
            if (type.equals("abc")) {
                type = "123";
                UiDevice.getInstance().click(tableAbc2Char[0], tableAbc2Char[1]);
                sleep(1000);
            }
            return true;
        } catch (NumberFormatException err) {
            //切换字母键盘
            if (!type.equals("abc")) {
                type = "abc";
                UiDevice.getInstance().click(tableAbc2Char[0], tableAbc2Char[1]);
                sleep(1000);
            }
            return false;
        }
    }

    private void showLog(String msg) {
        LogToFile.showLog("民生银行", msg);
    }
}